{% extends 'base.html' %}

{% block js %}
<script>
function sign_in() {
    var username = $("[name='username']").val();
    var raw_password = $("[name='raw_password']").val();

    $.post('/sign/in', {'username': username, 'raw_password': raw_password}, function (data) {
        if(data.success){
            window.location.href = '{{ next }}'
        }else{
            alert('用户名或密码错误')
            return false
        }
    })
}
</script>
{% endblock %}

{% block content %}
<div class="center_div">
    <input type="text" class="form-control" placeholder="用户名" required autofocus name="username">
    <br><br>
    <input type="password" class="form-control" placeholder="密码" required name="raw_password">
    <br><br>
    <button class="btn btn-lg btn-primary btn-block" onclick="sign_in()">登录</button>
    <br>
    <a href="/sign/up">还没有账号?去注册</a>
</div>
{% endblock %}